package com.git.controller;

import javax.servlet.http.HttpServletRequest;

import com.git.domain.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.git.domain.BaseDataResponse;
import com.git.domain.StudentEntity;
import com.git.domain.ResultCode;
import com.git.service.DemoService;

import java.util.List;

@RestController
public class StudentController {
	@Autowired
	private DemoService demoService;


	@RequestMapping("/getAll")
	public BaseDataResponse<List<StudentEntity>> getAll(HttpServletRequest request){
		List<StudentEntity> demoEntitys = this.demoService.getAll();
		return new BaseDataResponse<List<StudentEntity>>(ResultCode.SUCCESSFUL_CODE, demoEntitys);
	}
	@RequestMapping("/add")
	public BaseResponse add(HttpServletRequest request,StudentEntity studentEntity){
		this.demoService.add(studentEntity);
		return BaseResponse.SUCCESSFUL();
	}
	@RequestMapping("/deleteStudent")
	public BaseResponse deleteStudent(HttpServletRequest request,Integer id){
		this.demoService.deleteStudent(id);
		return BaseResponse.SUCCESSFUL();
	}

}
